package com.hundsun.s3.platform.monitor.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.hundsun.s3.common.dto.PageBean;
import com.hundsun.s3.common.dto.SR;
import com.hundsun.s3.common.util.BaseDao;
import com.hundsun.s3.monitor.service.MonitorService;


/**
 * 
 * <p>Title:MonitorServiceImpl</p>
 * <p>Description: </p>
 * <p>Company: Hundsun</p>
 * @author :zhangwc23609
 * @date :2018年2月8日 下午4:12:35
 */

@Service
public class MonitorServiceImpl extends BaseDao implements MonitorService {
	
	/**
     * @Description:根据员工id查询工单总数
     * @param:
     * @return:
     * @Author: zhangwc23609
     * @Date: 14:10 2018/3/2
     * V1.0
     */
	@Override
	public int getCountById(String staffId) {
		int count = 0;
		Map<String, Object> params = new HashMap<>();
		params.put("staffId", staffId);
		List<Map<String, String>> list = this.call("600102",params);
		if(list.size() != 0){
			Map<String, String> map = list.get(0);
			if(map.size() != 0){
				String sCount = map.get("totalCount");
				count = Integer.parseInt(sCount);
			}
		}
		return count;
	}
	
	/**
     * @Description:根据员工id分页查询
     * @param:
     * @return:
     * @Author: zhangwc23609
     * @Date: 14:43 2018/3/2
     * V1.0
     */
	@Override
	public Map<String, Object> getSRById(String staffId, PageBean pageBean) {
		int count = this.getCountById(staffId);
		pageBean.setCount(count);
		Map<String, Object> params = new HashMap<>();
		params.put("staffId", staffId);
		params.put("pageNo", pageBean.getPageNo());
		params.put("pageSize", pageBean.getPageSize());
		List<SR> list = this.qry("600101", params, SR.class);
		Map<String, Object> map = new HashMap<>();
		map.put("list", list);
		map.put("page", pageBean);
		return map;
	}

}
